<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>考勤报表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="/css/public.css" media="all">
</head>
<style>
    .layui-form-pane .layui-form-label {
        width: auto !important;
    }

    .layui-table-cell {
        height: auto !important;
        white-space: normal;
    }

</style>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">
        <fieldset class="table-search-fieldset">
            <legend>搜索信息</legend>
            <form class="layui-form layui-form-pane" action="">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">姓名</label>
                        <div class="layui-input-inline" style="width: 90px">
                            <input type="text" name="Name" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">设备ID</label>
                        <div class="layui-input-inline">
                            <input type="text" name="DeviceID" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <button type="submit" class="layui-btn layui-btn-primary" lay-submit
                                lay-filter="data-search-btn-name"><i class="layui-icon"></i> 查询
                        </button>
                    </div>
                </div>
            </form>
        </fieldset>

        <fieldset class="table-search-fieldset">
            <legend>数据记录</legend>
            <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>
        </fieldset>

    </div>
</div>
<script src="/lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form', 'table', 'tree', 'util', 'laydate', 'layer', 'element'], function () {
         $ = layui.jquery,
            form = layui.form,
            table = layui.table,
            laydate = layui.laydate,
            layer = layui.layer;


        table.render({
            elem: '#currentTableId',
            url: '/getVerifyPush',
            toolbar: '#toolbarDemo',
            width: 1250,
            defaultToolbar: ['filter', 'exports', 'print', {
                title: '提示',
                layEvent: 'LAYTABLE_TIPS',
                icon: 'layui-icon-tips'
            }],
            parseData:function(msg){
                for (let i = 0; i < msg.data.length; i++) {
                    msg.data[i].verfyType=`${msg.data[i].verfyType}`.replace(0,"普通人员").replace(1,"白名单").replace(2,"黑名单");
                    msg.data[i].temperatureAlarm=`${msg.data[i].temperatureAlarm}`.replace(0,"正常").replace(1,"异常");
                }
                return msg;
            },
            cols: [
                [
                    {field: 'name', width: 100, title: '姓名'},
                    {field: 'createTime', width: 200, title: '测温时间', sort:true},
                    {field: 'deviceID', width: 200, title: '设备地址'},
                    {field: 'verfyType', width: 170, title: '人员角色'},
                    {field: 'temperature', width: 100, title: '温度'},
                    {field: 'temperatureAlarm', width: 100, title: '状态'}
                ]
            ],
            limits: [10, 20, 25, 35, 50, 100],
            limit: 5,
            page: true
        });

        // 监听搜索操作:地点
        form.on('submit(data-search-btn-location)', function (data) {
            let result = JSON.stringify(data.field);
            layer.alert(result, {
                title: '最终的搜索信息'
            });

            //执行搜索重载
            table.reload('currentTableId', {
                page: {
                    curr: 1
                }
                , where: {
                    searchParams: result
                }
            }, 'data');

            return false;
        });
        // 监听搜索操作：姓名
        form.on('submit(data-search-btn-name)', function (data) {
            let result = JSON.stringify(data.field);
            layer.alert(result, {
                title: '最终的搜索信息'
            });

            //执行搜索重载
            table.reload('currentTableId', {
                page: {
                    curr: 1
                }
                , where: {
                    searchParams: result
                }
            }, 'data');

            return false;
        });
        // 监听搜索操作：时间
        form.on('submit(data-search-btn-date)', function (data) {
             result = JSON.stringify(data.field);
            layer.alert(result, {
                title: '最终的搜索信息'
            });

            //执行搜索重载
            table.reload('currentTableId', {
                page: {
                    curr: 1
                }
                , where: {
                    searchParams: result
                }
            }, 'data');

            return false;
        });
        //日期时间选择器
        laydate.render({
            elem: '#dateStart'
            , type: 'datetime'
        });
        //日期时间选择器
        laydate.render({
            elem: '#dateEnd'
            , type: 'datetime'
        });
    });
</script>
</body>
</html>